{% extends "admin/base_site_nav.html" %}
{% load i18n admin_modify %}

{% block extrahead %}{{block.super}}
{{media}}
{% endblock %}

{% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}admin/css/forms.css" />
<style>

li, dt, dd {
  font-size: inherit;
  line-height: inherit;
}

#content-main .form-control {
  width: calc(100% - 45px);
  display: inline-block;
}

#content-main .form-control-inline {
  width: 100%;
}

#content-main select.form-control {
  width: auto;
  display: inline-block;
}

#content-main .vDateField, .row .vTimeField {
  width: calc(100% - 100px);
  max-width: 150px;
}

#content-main input[type=number] {
  max-width: 150px;
}

.form-row p, td, th {
  font-family: inherit
}

.inline-related fieldset {
  background: none;
}

fieldset th {
  font-weight: normal;
}

._inline-group .form-control {
  width: 100% !important;
  font-weight: normal;
}

._inline-group input[type=number], ._inline-group .vDateField, ._inline-group .vTimeField {
  width: 100% !important;
  max-width: 400px !important;
}

@media (min-width: 992px) {
  #content-main .control-label {
    text-align: right;
  }
}
</style>
{{block.super}}{% endblock %}

{% block content_title %}{{ block.super }}{% if object_id %}{% tabs opts %}{% endif %}{% endblock %}

{% block content %}<div id="content-main" class="row"><div class="col-md-12">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
{% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
{% if errors %}
    <div class="row"><div class="col-md-12"><div class="alert alert-danger">
    {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}
    {% trans "Please correct the errors below." %}{% endif %}
    {{ adminform.form.non_field_errors }}
    </div></div></div>
{% endif %}

{% block field_sets %}
{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}
{% endblock %}

{% block after_field_sets %}{% endblock %}

{% block inline_field_sets %}
{% for inline_admin_formset in inline_admin_formsets %}
    {% include inline_admin_formset.opts.template %}
{% endfor %}
{% endblock %}

{% block after_related_objects %}{% endblock %}

{% block admin_change_form_document_ready %}
    <script>
        (function($) {
            $(document).ready(function() {
                $('.add-another').click(function(e) {
                    e.preventDefault();
                    showAddAnotherPopup(this);
                });
                $('.related-lookup').click(function(e) {
                    e.preventDefault();
                    showRelatedObjectLookupPopup(this);
                });
            {% if adminform and add %}
                $('form#{{ opts.model_name }}_form :input:visible:enabled:first').focus()
            {% endif %}
            });
        })(django.jQuery);
    </script>
{% endblock %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</form>
</div></div>
{% endblock %}
